/************************************\
|* unittest3.c                      *|
|* By Danny Burrows                 *|
|* burrowsd@onid.oregonstate.edu    *|
|* CS362 - Spring 2014              *|
|*                                  *|
|* Assignment 3                     *|
|*                                  *|
|* Simple unit tests of the         *|
|* drawCard function inside of      *|
|* dominion.c                       *|
\************************************/

#include <stdio.h>
#include <stdlib.h>
#include "dominion.h"

void checkTest(char *string, int expected, int result)
{
	if (expected == result)
		printf("PASS - %s: expected - %d, result - %d\n", string, expected, result);
	else
		printf("FAIL - %s: expected - %d, result - %d\n", string, expected, result);

	return;
}

void runTests(struct gameState *game)
{
	/* int drawCard(int player, struct gameState *state) */
	int *k = malloc(sizeof(int) * 10);

	game->handCount[0] = 5;
	game->deckCount[0] = 5;
	checkTest("handCount", 5, game->handCount[0]);
	checkTest("deckCount", 5, game->deckCount[0]);
	
	for (int i = 1; i <= 10; ++i)
	{
		/* pull one card from the deck and place it in the hand */	
		if ( (drawCard(0, game)) != -1 ) {
			checkTest("handCount", 5 + i, game->handCount[0]);
			checkTest("deckCount", 5 - i, game->deckCount[0]);
		} else {
			printf("Cannot draw card\n");
		}
	}

	return;
}

int main(int argc, char const *argv[])
{
	struct gameState *game = malloc(sizeof(struct gameState));

	runTests(game);

	free(game);

	return 0;
}